<%@ page import="java.util.List" %>
<%@page pageEncoding="UTF-8" contentType="text/html; UTF-8" isELIgnored="false" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>分类列表</title>
    <script>
        // 确认删除的函数
        function confirmDelete(url) {
            return confirm("您确定要删除这个分类吗？\n请确保您已删除该分类下的所有商品。");
        }
    </script>
</head>
<body>
<%
    if (session.getAttribute("kind_msg") != null)
    {
%>
<h2><%= session.getAttribute("kind_msg") %></h2>
<%
    }
%>
<h2>登录成功，欢迎 <%= session.getAttribute("username") %></h2>
<%
    List<Object[]> kindList = (List<Object[]>) session.getAttribute("kindList");
%>
<table>
    <tr>
        <td>编号</td>
        <td>种类</td>
        <td>描述</td>
        <td>操作</td>
    </tr>
    <%
        if(kindList!=null){
            for (Object[] kind : kindList) {
    %>
    <tr>
        <td> <%=kind[0]%> </td>
        <td> <%=kind[1]%> </td>
        <td> <%=kind[2]%> </td>
        <td> <a href="edit_kind.jsp?kindId=<%=kind[0]%>&&kind=<%=kind[1]%>">编辑</a> </td>
        <td> <a href="delKind?kind=<%=kind[1]%>" onclick="return confirmDelete('delKind?kind=<%=kind[1]%>')">删除</a> </td>
        <td> <a href="getAllTVs?kind=<%=kind[1]%>">查看</a> </td>
    </tr>
    <%
            }
        }
    %>
</table>
<a href="add_kind.jsp">添加类别</a>
<br>
<br>
<form action="logout" method="post">
    <input type="submit" value="退出登录">
</form>
</body>
</html>